import router from './router'
import { getAccessToken } from '@/utils/auth'

router.beforeEach((to, from, next) => {
  console.log('to,',to, 'form',from);
  console.log('getAccessToken', getAccessToken());
  
  // 直接放行所有路由，无需验证登录状态
  if(to.path === '/') {
    next({ path: '/login' })
  }  else if (!getAccessToken()) {
    next({ path: '/login' })
  } else {
    next()
  }
})

router.afterEach(() => {
})